presentation.graph
Class GraphFactory

java.lang.Object
  extended by presentation.graph.GraphFactory

public class GraphFactory
extends java.lang.Object

Factory to create a JGraph object from a Service


Field Summary
private  java.util.HashMap<StateAction,org.jgraph.graph.DefaultEdge> edgeMap
           
private  org.jgraph.JGraph graph
           
static java.lang.String[] layouts
           
private  java.util.HashMap<State,org.jgraph.graph.DefaultGraphCell> vertexMap
           
 
Constructor Summary
GraphFactory(Service service)
          Create a new GraphFactory
 
Method Summary
static void changeRepresentation(org.jgraph.JGraph graph, java.lang.String layout)
          Change the layout of the graph
static org.jgraph.graph.DefaultEdge createEdge(java.lang.String edge, org.jgraph.graph.DefaultGraphCell source, org.jgraph.graph.DefaultGraphCell target)
          create an edge
private  void createGraph(Service service)
          Create a JGraph component from service
static org.jgraph.graph.DefaultGraphCell createVertex(java.lang.String node, boolean isFinalState)
          create a vertex
 java.util.HashMap<StateAction,org.jgraph.graph.DefaultEdge> getEdgeMap()
          Return an hash map key: action of service value: edge of graph
 org.jgraph.JGraph getGraph()
          return the generated graph
 java.util.HashMap<State,org.jgraph.graph.DefaultGraphCell> getVertexMap()
          Return an hash map key: state of service value: vertex of graph
static void selectEdge(org.jgraph.JGraph graph, org.jgraph.graph.DefaultEdge edge, boolean select)
          Change the color of the edge
static void selectVertex(org.jgraph.JGraph graph, org.jgraph.graph.DefaultGraphCell cell, boolean select)
          Change the color of the vertex
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

graph

private org.jgraph.JGraph graph

vertexMap

private java.util.HashMap<State,org.jgraph.graph.DefaultGraphCell> vertexMap

edgeMap

private java.util.HashMap<StateAction,org.jgraph.graph.DefaultEdge> edgeMap

layouts

public static final java.lang.String[] layouts
Constructor Detail

GraphFactory

public GraphFactory(Service service)
Create a new GraphFactory

Parameters:
service - the service
Method Detail

getGraph

public org.jgraph.JGraph getGraph()
return the generated graph

Returns:
the graph

getVertexMap

public java.util.HashMap<State,org.jgraph.graph.DefaultGraphCell> getVertexMap()
Return an hash map key: state of service value: vertex of graph

Returns:
the map

getEdgeMap

public java.util.HashMap<StateAction,org.jgraph.graph.DefaultEdge> getEdgeMap()
Return an hash map key: action of service value: edge of graph

Returns:
the map

createGraph

private void createGraph(Service service)
Create a JGraph component from service

Parameters:
service - the selected service

createVertex

public static org.jgraph.graph.DefaultGraphCell createVertex(java.lang.String node,
                                                             boolean isFinalState)
create a vertex

Parameters:
node - the name of the vertex
isFinalState - true if node is final
Returns:
the vertex

createEdge

public static org.jgraph.graph.DefaultEdge createEdge(java.lang.String edge,
                                                      org.jgraph.graph.DefaultGraphCell source,
                                                      org.jgraph.graph.DefaultGraphCell target)
create an edge

Parameters:
edge - the name of the action
source - source vertex
target - target vertex
Returns:
the edge

selectVertex

public static void selectVertex(org.jgraph.JGraph graph,
                                org.jgraph.graph.DefaultGraphCell cell,
                                boolean select)
Change the color of the vertex

Parameters:
graph - the graph
cell - the selected vertex
select - the vertex is blue if true or it is black if false

selectEdge

public static void selectEdge(org.jgraph.JGraph graph,
                              org.jgraph.graph.DefaultEdge edge,
                              boolean select)
Change the color of the edge

Parameters:
graph - the graph
edge - the selected edge
select - the edge is red if true or black if false

changeRepresentation

public static void changeRepresentation(org.jgraph.JGraph graph,
                                        java.lang.String layout)
Change the layout of the graph

Parameters:
graph - the graph
layout - the name of the layout